package com.arron.jvm;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

/**
 * @Classname Resource
 * @Description TODO
 * @Date 2020/8/18 22:18
 * @Created by 刘
 */
public class Resource {

    //volatile保证可见性，有序性，不保证原子性
//    volatile int num = 0;

    AtomicInteger num = new AtomicInteger(0);

    LongAdder adder = new LongAdder();

    public void changeNum() {
        num = new AtomicInteger(10);
    }
    public  void addPlusPlus(){
        num.getAndIncrement();

    }

    public  void addPlusPlusPlus(){
       adder.add(1);
    }

}